import {
  AppStateInterface,
  AppActionTypes,
  UPDATE_WEB_NAV_INDEX,
  UPDATE_TEST_DATA,
} from './types'

 export const initialStateApp: AppStateInterface = {
  webNavIndex: '',
  testNum: 111
}

export default (initialState: AppStateInterface) => {
  return function(
    state = initialState,
    action: AppActionTypes
  ): AppStateInterface {
    switch (action.type) {
      case UPDATE_WEB_NAV_INDEX: {
        return {
          ...state,
          webNavIndex: action.value
        }
      }
      case UPDATE_TEST_DATA: {
        return {
          ...state,
          testNum: action.value
        }
      }
      default:
        return state
    }
  }
}